<?php

class Q {
const SPRITE_NONE     = 0;
const SPRITE_DEFAULT  = 1;
const SPRITE_PARTICLE = 2;
const SPRITE_ACTIVE   = 4;
const SPRITE_FRIENDLY = 8;
const SPRITE_ENEMY    = 16;
const SPRITE_UI       = 32;
const SPRITE_PLAYER	  = 256;
const SPRITE_PLAYER_SHOT	  = 512;
const SPRITE_ALL   = 0xFFFF;
}

$a = new stdClass();
$a->type = Q::SPRITE_PLAYER;
$a->mask = Q::SPRITE_ALL & ~(Q::SPRITE_PLAYER_SHOT);


$b = new stdClass();
$b->type = Q::SPRITE_PLAYER_SHOT;
$b->mask = Q::SPRITE_ALL & ~(Q::SPRITE_PLAYER);


$c = new stdClass();
$c->type = Q::SPRITE_DEFAULT | Q::SPRITE_ACTIVE | Q::SPRITE_ENEMY;
$c->mask = Q::SPRITE_ALL & ~(Q::SPRITE_PARTICLE | Q::SPRITE_ENEMY);


$d = new stdClass();
$d->type = Q::SPRITE_PARTICLE | Q::SPRITE_ENEMY;
$d->mask = Q::SPRITE_ALL & ~(Q::SPRITE_ENEMY);


var_dump($a->mask & $b->type);
var_dump($a->type & $b->mask);


?>